home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
Mandlebrot
/
Mandlebrot Folder
/
Mandelbrot.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-07
|
5KB
|
183 lines
/* *********************************************************************************
FILE: Mandelbrot.c
DESCRIPTION: Translated from Mandel -- Pascal Application in "On MacIntosh
Programming: Advanced Techniques", Daniel K. Allen,
Addison-Wesley, 1989 pp. 88-100
AUTHOR: Bruce E. Gladstone
Copyright © 1990 by Bruce E. Gladstone, All Rights Reserved.
Revision History:
============================================================
5/1/90 - Release to Compuserve
============================================================
COMMENTS:
None.
******************************************************************************** */
#include <stdio.h>
#include <QuickDraw.h>
#include <MacTypes.h>
#include <WindowMgr.h>
#include <MenuMgr.h>
#include <EventMgr.h>
#include <DeskMgr.h>
#include <FileMgr.h>
#include <ToolboxUtil.h>
#include <ControlMgr.h>
#include <color.h>
#include <colortoolbox.h>
#include "Mandelbrot.h"
/* ---------------------------- Global Variables ---------------------------------- */
int colorQD;
int quitFlag;
int linearFlag;
int custPict;
int numColorBits;
int numColors, brushSize;
int limit;
int n;
long startTime, now;
float res;
float centx, centy;
float xmin, xmax, ymin, ymax;
float delx, dely;
/* ---------------------------- Global MacTypes ----------------------------------- */
Str255 str;
CTabHandle myColorHandle;
RGBColor aColor;
Rect myRect, dragRect;
WindowPtr aboutWindow;
MenuHandle appleMenu, mandelMenu, editMenu, xMenu, yMenu, resMenu, timeMenu;
WindowPtr myWindow;
/* --------------------------- Local Prototypes --------------------------------- */
int main ( void );
void initWorld ( void );
void drawMandel ( void );
void menuBarInit ( void );
void windowInit ( void );
/* --------------------------------------------------------------------------------
main - 5/01/90 beg
-------------------------------------------------------------------------------- */
int
main()
{
initWorld ();
while ( !quitFlag )
{
startTime = TickCount();
drawMandel ();
}
DisposeWindow ( myWindow );
return (0); /* Back to shell */
} /* main */
/* --------------------------------------------------------------------------------
initWorld - 5/01/90 beg
Initialization code: makes the window, builds the menus, sets the colors
sets up the default Mandelbrot parms
-------------------------------------------------------------------------------- */
void
initWorld ()
{
MaxApplZone ();
InitGraf ( &thePort );
InitFonts ();
InitWindows ();
InitMenus ();
TEInit ();
InitDialogs ( nil );
InitCursor();
menuBarInit();
windowInit();
FlushEvents ( everyEvent,0 );
/* Mandel defaults */
centx = -0.8;
centy = 0.0;
res = 1.0;
limit = 256;
linearFlag = FALSE;
custPict = 1;
quitFlag = FALSE;
brushSize = 8;
} /* initWorld () */
/* --------------------------------------------------------------------------------
menuBarInit - 5/01/90 beg
-------------------------------------------------------------------------------- */
void
menuBarInit()
{
Handle mandelMenuBar;
mandelMenuBar = GetNewMBar ( appleID );
SetMenuBar ( mandelMenuBar );
appleMenu = GetMHandle ( appleID );
AddResMenu ( appleMenu, 'DRVR' );
mandelMenu = GetMHandle ( mandelID );
editMenu = GetMHandle ( editID );
CheckItem ( mandelMenu, 2, TRUE );
CheckItem ( mandelMenu, 5, TRUE );
CheckItem ( mandelMenu, 11, TRUE );
DrawMenuBar();
} /* menuBarInit() */
/* --------------------------------------------------------------------------------
windowInit - 5/01/90 beg
-------------------------------------------------------------------------------- */
void
windowInit()
{
long cflag;
cflag = ROM85;
SetRect ( &dragRect, -32768, -32768, 32767, 32767 );
myRect = screenBits.bounds;
myRect.top += 45;
myRect.left += 10;
myRect.right -= 10;
myRect.bottom -= 10;
colorQD = (*((int*)cflag) & 0xC000) == 0;
if ( colorQD )
{
myWindow = NewCWindow(nil, &myRect, "\pMandel", TRUE, zoomDocProc,
(CWindowPtr)-1, TRUE, 0);
numColorBits = (**(*(CGrafPtr)myWindow).portPixMap).pixelSize;
numColors = 1 << numColorBits;
myColorHandle = GetCTable ( numColorBits ); /* Should get default clut */
}
else
{
myWindow = NewWindow(nil, &myRect, "\pMandel", TRUE, zoomDocProc,
(CWindowPtr)-1, TRUE, 0);
}
SetPort ( myWindow );
} /* windowInit() */
/* =============================== EOF ==========================================
Copyright © 1990 by Bruce E. Gladstone, All Rights Reserved.
================================================================================ */